//
//  MineUserInfoView.m
//  ExhibitionHall
//
//  Created by 王洋 on 2019/6/3.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "MineUserInfoView.h"

@implementation MineUserInfoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self layout];
    }
    return self;
}

- (void)fillMineHeaderWithModel:(MineUserInfoModel *)model {
    
    self.userNameLab.text = model.userName;
    [self.userIconBtn sd_setImageWithURL:[NSURL URLWithString:model.userIconURL]];
}

- (void)layout {
    
    [self addSubview:self.userIconBtn];
    [self addSubview:self.userNameLab];
    
    [self.userIconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.width.height.mas_equalTo(100);
        make.top.mas_equalTo(40);
    }];
    
    [self.userNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.userIconBtn.mas_bottom).offset(20);
        make.centerX.mas_equalTo(self);
    }];
    
}


- (UIImageView *)userIconBtn {
    if (!_userIconBtn) {
        _userIconBtn = [[UIImageView alloc] init];;
        _userIconBtn.layer.cornerRadius = 50;
        [_userIconBtn setBackgroundColor:[UIColor lightGrayColor]];
        _userIconBtn.clipsToBounds = YES;
    }
    return _userIconBtn;
}

- (UILabel *)userNameLab {
    if (!_userNameLab) {
        _userNameLab = [[UILabel alloc] init];
        _userNameLab.textAlignment = NSTextAlignmentCenter;
    }
    return _userNameLab;
}
@end
